package view;

import java.awt.*;
import model.Leaderboard;

public class LeaderboardView {
    private Leaderboard leaderboard;
    public LeaderboardView(Leaderboard leaderboard) {
        this.leaderboard = leaderboard;
    }
    public void draw(Graphics g, int x, int y, int score) {
        g.setColor(Color.WHITE);
        g.setFont(new Font("Arial", Font.BOLD, 22));
        g.drawString("得分: " + score, x, y);
        y += 40;
        int rank = 1;
        int total = leaderboard.getScores().length;
        int[] scores = leaderboard.getScores();
        for (int i = 0; i < scores.length; i++) {
            if (score < scores[i]) rank++;
        }
        g.setFont(new Font("Arial", Font.PLAIN, 18));
        g.drawString("当前名次: 第" + rank + "名/共" + (total + 1) + "人", x, y);
    }
} 